package com.magold.io.helper;

import com.badlogic.gdx.math.Vector2;
import com.magold.io.XMLDataAccessor;

public class ReaderFacade {

	public static Vector2 getVector2(XMLDataAccessor pReader, String pCommonPrefix) {
		return getVector2(pReader, pCommonPrefix, new Vector2());
	}

	public static Vector2 getVector2(XMLDataAccessor pReader, String pCommonPrefix, Vector2 pContainner) {
		float x = pReader.getFloat(pCommonPrefix + "_x");
		float y = pReader.getFloat(pCommonPrefix + "_y");
		pContainner.set(x, y);
		return pContainner;
	}
	
	public static float[] getArray(XMLDataAccessor pReader, String pKey, String pSplit) {
		String[] xValues = pReader.getString(pKey).split(pSplit);
		int size = xValues.length;
		float[] xCoors = new float[size];
		for (int i = 0; i < size; i++) {
			xCoors[i] = Float.parseFloat(xValues[i]);
		}

		return xCoors;
	}
}
